<?php 

function add_employee($name,$typeid,$phone,$address,$email)
{
	$sql = "INSERT INTO ".TB_PREF."employees (empname, typeid, phone, address, email) values (".db_escape($name).",".db_escape($typeid).",".db_escape($phone).",".db_escape($address).",".db_escape($email).")";
	db_query($sql,"The employee could not be added");
}

function update_employee($id,$name,$typeid,$phone,$address,$email)
{
	$sql = "UPDATE ".TB_PREF."employees SET empname=" . db_escape($name) . ", 
		typeid=" . db_escape($typeid) . ",
		phone=" . db_escape($phone) . ",
		address=" . db_escape($address) . ",
		email=" . db_escape($email) . "
		WHERE empid = ".db_escape($id);

	db_query($sql,"The employee could not be updated");
}

function delete_employee($id)
{
	$sql = "DELETE FROM ".TB_PREF."employees WHERE empid=".db_escape($id);;
	db_query($sql,"cannot delete employee");	
}

function get_employees($show_inactive)
{
	$sql = "SELECT * FROM ".TB_PREF."employees_type INNER JOIN employees ON (employees_type.typeid = employees.typeid)";
	if (!$show_inactive) $sql .= " WHERE not inactive";
	return db_query($sql,"could not get employees");
}

function get_employee($selected_id)
{
	$sql = "SELECT *  FROM ".TB_PREF."employees WHERE empid=".db_escape($selected_id);

	$result = db_query($sql,"could not get employee");
	return db_fetch($result);
}


?>